Component({
  properties: {
    // 卡片数据
    activityId: {
      type: [String, Number],
      value: 0
    },
    eventTitle: {
      type: String,
      value: '一起爬山吗？'
    },
    bannerImage: {
      type: String,
      value: 'https://via.placeholder.com/400x360/4a90e2/ffffff?text=默认活动'
    },
    tag1: {
      type: String,
      value: '热门活动'
    },
    tag2: {
      type: String,
      value: '立即参与'
    },
    status: {
      type: String,
      value: '报名中'
    },
    eventName: {
      type: String,
      value: '周末爬山活动'
    },
    signedUpCount: {
      type: Number,
      value: 0
    },
    maxParticipants: {
      type: Number,
      value: 100
    },
    buttonText: {
      type: String,
      value: '去报名'
    },
    
    // 状态标签颜色
    statusColor: {
      type: String,
      value: '#07C160' // 默认绿色
    }
  },

  data: {
    countdown: {
      days: '03',
      hours: '10',
      minutes: '37',
      seconds: '11'
    }
  },

  lifetimes: {
    attached() {
      // 组件挂载完成
    }
  },
  
  data: {
    countdown: {
      days: '03',
      hours: '10',
      minutes: '37',
      seconds: '11'
    }
  },

  methods: {
    // 图片加载错误处理
    onImageError(e) {
      console.error('图片加载失败:', e.detail);
      // 可以设置默认图片
      this.setData({
        bannerImage: 'https://via.placeholder.com/400x360/cccccc/666666?text=活动图片'
      });
    },

    // 图片加载完成事件
    onImageLoad(e) {
      // 向父组件传递图片加载完成事件
      this.triggerEvent('imageload', {
        width: e.detail.width,
        height: e.detail.height
      });
    },

    // 卡片点击事件 - 跳转到活动详情页
    onCardTap() {
      const activityId = this.properties.activityId;
      console.log('点击活动卡片，ID:', activityId);
      
      wx.navigateTo({
        url: `/pages/activity_detail/index?id=${activityId}`,
        success: () => {
          console.log('成功跳转到活动详情页');
        },
        fail: (err) => {
          console.error('跳转失败:', err);
        }
      });
    },
    
    // 启动倒计时（示例）
    startCountdown(endTime) {
      const timer = setInterval(() => {
        const now = new Date().getTime();
        const diff = endTime - now;
        
        if (diff <= 0) {
          clearInterval(timer);
          this.setData({ 
            status: '已结束',
            statusColor: '#CCCCCC'
          });
          return;
        }
        
        const days = Math.floor(diff / (1000 * 60 * 60 * 24)).toString().padStart(2, '0');
        const hours = Math.floor((diff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)).toString().padStart(2, '0');
        const minutes = Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60)).toString().padStart(2, '0');
        const seconds = Math.floor((diff % (1000 * 60)) / 1000).toString().padStart(2, '0');
        
        this.setData({ 
          countdown: { days, hours, minutes, seconds } 
        });
      }, 1000);
    }
  }
})